# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=swww
pkgver=0.8.1
pkgrel=0
pkgdesc="Efficient animated wallpaper daemon for Wayland compositors"
url="https://github.com/Horus645/swww"
arch="all !s390x" # Build failed
license="GPL-3.0-or-later"
makedepends="scdoc cargo libxkbcommon-dev wayland-dev cargo-auditable"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/Horus645/swww/archive/refs/tags/v$pkgver.tar.gz"
options="!check" # Requires the binary to be available in PATH

prepare() {
	default_prepare

	# Busybox's basename applet doesn't implement --suffix argument
	sed -i 's/--suffix/-s/' doc/gen.sh

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
	sh ./doc/gen.sh
}

package() {
	for binary in swww swww-daemon; do
		install -Dm755 target/release/$binary -t "$pkgdir"/usr/bin/
	done

	install -Dm644 doc/generated/*.1 -t "$pkgdir"/usr/share/man/man1/

	install -Dm644 completions/swww.bash \
		"$pkgdir"/usr/share/bash-completion/completions/swww
	install -Dm644 completions/swww.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/swww.fish
	install -Dm644 completions/_swww \
		"$pkgdir"/usr/share/zsh/site-functions/_swww
}

sha512sums="
a1dc56b3e7ab157519b87d90f0ae0edb963169c3618d982fe10cce8f00896bcd3d453ae21b0976cba284924fa00a98927c47602eb0bb3d8a467fb93f442fe931  swww-0.8.1.tar.gz
"
